[]
Array access operator - [] - say what?
Video Transcript
00:00So this is really the last topic that I wanted to talk about in arrays
00:03But it's not really a new topic more than a shortcut of how to do something you really know how to do already
00:10We've seen with objects that we could create an object in a few different ways
00:14We could create a new object by just typing a new object
00:17We've seen that before or if we wanted to we could have created our object in a shortcut way, right?
00:23We said we could just open a curly bracket close a curly bracket
00:27and we even could have opened up a new object and
00:32Set into that object properties directly
00:36Okay
00:44So this is an example of how we could work with an object setting its values directly into the object in a shortcut
00:50Same thing with the array so far. We've seen how to create a new array
00:55Instead of building our array in this way would there is a shortcut as well. So array and
01:02And we would open a bracket close a bracket as before but this time around we could just grab all the stuff
01:08We've done in our new array and just paste it directly in and we've just created a
01:14Shortcut to creating an array and you could see it's not a huge shortcut, but it saves some time
01:20In a lot of times you're going to see that other programmers tend to use it
01:23I tend to use it often. I rarely ever well, I never really type new array or new object
01:29Although I would use the new for everything but those two
01:32But we were using the new to kind of make sure that you understand what's actually happening behind the hood
01:37So now that you know what's happening behind the hood
01:40You could choose to work in this way or you could choose to use this the shortcut whatever you're more comfortable with
